Show progress bar while loading registry #2617
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Refreshing the mod list in GUI involves two steps:
Step 2 can take several seconds. While it's happening, the window freezes, because the intensive processing is done on the GUI thread (whereas step 1 has a progress bar). The freeze also happens when switching instances and changing version compatibility.
Changes
Now while the mod list is loading, the processing takes place in a background thread, and the progress bar screen is shown with messages indicating which step we're on (helpful for identifying slow pieces!):
This keeps the UI responsive and assures the user that it hasn't crashed. When finished, the tab is hidden.
Side performance tweak
While implementing this, I found out that the slowest step is
Registry.Available
, with a typical run time of up to a few seconds (I thought it would be loading the data from theregistry.json
file).Unrelated to the above changes, this function was always called at the end of a repo update, but that was just to generate an
int
return value that isn't even used most of the time. So now those functions returnbool
and just returntrue
instead of callingRegistry.Available
, and calling code is updated to callRegistry.Available
when it's actually needed. This should slightly speed up refreshes in GUI.